******************************************************************************************
***Do Safety Expectations Affect the Location Strategies of Large Service Delivergy INGOs?
***Replication Files
******************************************************************************************

import excel "C:\Users\ascot\OneDrive - East Carolina University\Under review\Paper - service INGOs\data and replication\INGOs - dataset.xlsx", sheet("Data") firstrow

*******************
***data preparation
*******************

ssc install PPML

destring, replace 

xtset ccode year

sort country year
by country: gen lagOPS12 = Ops12_count[_n-1] if year==year[_n-1]+1
by country: gen lagOPS1 = Ops1_count[_n-1] if year==year[_n-1]+1
by country: gen lagOPS2 = Ops2_count[_n-1] if year==year[_n-1]+1

by country: gen hclagOPS12 = Ops12_highconf[_n-1] if year==year[_n-1]+1
by country: gen hclagOPS1 = Ops1_highconf[_n-1] if year==year[_n-1]+1
by country: gen hclagOPS2 = Ops2_highconf[_n-1] if year==year[_n-1]+1


***********************
***Table 4: Main models
***********************

nbreg lagOPS1 democracy ciri_orgrights gtd_ngoterror gdppcln pop_ln lnaidpc_adj prio_civwar ciri_physint i.region, cluster (ccode)
outreg2 using table20, replace

nbreg lagOPS2 democracy ciri_orgrights gtd_ngoterror gdppcln pop_ln lnaidpc_adj prio_civwar ciri_physint i.region, cluster (ccode)
outreg2 using table20

nbreg lagOPS12 democracy ciri_orgrights gtd_ngoterror gdppcln pop_ln lnaidpc_adj prio_civwar ciri_physint i.region, cluster (ccode)
outreg2 using table20


********************************************
***Margin effects: Democracy and low-intensity ops
********************************************

nbreg lagOPS1 democracy ciri_orgrights gtd_ngoterror gdppcln pop_ln lnaidpc_adj prio_civwar ciri_physint i.region, cluster (ccode)

margins, at (democracy = (0 1)) vsquish
marginsplot

********************************************
***Figure 2: Orgrights and low-intensity ops
********************************************

nbreg lagOPS1 democracy ciri_orgrights gtd_ngoterror gdppcln pop_ln lnaidpc_adj prio_civwar ciri_physint i.region, cluster (ccode)

margins, at (ciri_orgrights = (0 (1) 8)) vsquish
marginsplot


*********************************************
***Margin effects: Democracy and high-intensity ops
*********************************************

nbreg lagOPS2 democracy ciri_orgrights gtd_ngoterror gdppcln pop_ln lnaidpc_adj prio_civwar ciri_physint i.region, cluster (ccode)

margins, at (democracy = (0 1)) vsquish
marginsplot


********************************************
***Margin effects: Democracy and both types of ops
********************************************

nbreg lagOPS12 democracy ciri_orgrights gtd_ngoterror gdppcln pop_ln lnaidpc_adj prio_civwar ciri_physint i.region, cluster (ccode)

margins, at (democracy = (0 1)) vsquish
marginsplot


****************************************************************************************
*Appendix*
****************************************************************************************

******************************************************************
***Appendix A1: Main models with Poisson pseudo-maximum likelihood
******************************************************************

xtset ccode year

xi: ppml lagOPS1 democracy ciri_orgrights gtd_ngoterror gdppcln pop_ln lnaidpc_adj prio_civwar ciri_physint i.region, cluster (ccode)
outreg2 using table20, replace

xi: ppml lagOPS2 democracy ciri_orgrights gtd_ngoterror gdppcln pop_ln lnaidpc_adj prio_civwar ciri_physint i.region, cluster (ccode)
outreg2 using table20

xi: ppml lagOPS12 democracy ciri_orgrights gtd_ngoterror gdppcln pop_ln lnaidpc_adj prio_civwar ciri_physint i.region, cluster (ccode)
outreg2 using table20


**************************************************
***Appendix A2: Main models with linear regression
**************************************************

reg lagOPS1 democracy ciri_orgrights gtd_ngoterror gdppcln pop_ln lnaidpc_adj prio_civwar ciri_physint i.region, cluster (ccode)
outreg2 using table20, replace

reg lagOPS2 democracy ciri_orgrights gtd_ngoterror gdppcln pop_ln lnaidpc_adj prio_civwar ciri_physint i.region, cluster (ccode)
outreg2 using table20

reg lagOPS12 democracy ciri_orgrights gtd_ngoterror gdppcln pop_ln lnaidpc_adj prio_civwar ciri_physint i.region, cluster (ccode)
outreg2 using table20


*****************************************
***Table A3: V-Dem democracy substitution
*****************************************

nbreg lagOPS1 v2_democracy ciri_orgrights gtd_ngoterror gdppcln pop_ln lnaidpc_adj prio_civwar ciri_physint i.region, cluster (ccode)
outreg2 using table20, replace

nbreg lagOPS2 v2_democracy ciri_orgrights gtd_ngoterror gdppcln pop_ln lnaidpc_adj prio_civwar ciri_physint i.region, cluster (ccode)
outreg2 using table20

nbreg lagOPS12 v2_democracy ciri_orgrights gtd_ngoterror gdppcln pop_ln lnaidpc_adj prio_civwar ciri_physint i.region, cluster (ccode)
outreg2 using table20


********************************************
***Appendix A4: V-Dem CSO index substitution
********************************************

nbreg lagOPS1 democracy vdem_csreprss_ord gtd_ngoterror gdppcln pop_ln lnaidpc_adj prio_civwar ciri_physint i.region, cluster (ccode)
outreg2 using table20, replace

nbreg lagOPS2 democracy vdem_csreprss_ord gtd_ngoterror gdppcln pop_ln lnaidpc_adj prio_civwar ciri_physint i.region, cluster (ccode)
outreg2 using table20

nbreg lagOPS12 democracy vdem_csreprss_ord gtd_ngoterror gdppcln pop_ln lnaidpc_adj prio_civwar ciri_physint i.region, cluster (ccode)
outreg2 using table20


**********************************
***Appendix A5: Non-Western sample
**********************************

nbreg lagOPS1 democracy ciri_orgrights gtd_ngoterror gdppcln pop_ln lnaidpc_adj prio_civwar ciri_physint i.region if western == 0, cluster (ccode)
outreg2 using table20, replace

nbreg lagOPS2 democracy ciri_orgrights gtd_ngoterror gdppcln pop_ln lnaidpc_adj prio_civwar ciri_physint i.region if western == 0, cluster (ccode)
outreg2 using table20

nbreg lagOPS12 democracy ciri_orgrights gtd_ngoterror gdppcln pop_ln lnaidpc_adj prio_civwar ciri_physint i.region if western == 0, cluster (ccode)
outreg2 using table20


*****************************************
***Appendix A6: High-confidence DV sample
*****************************************

nbreg hclagOPS1 democracy ciri_orgrights gtd_ngoterror gdppcln pop_ln lnaidpc_adj prio_civwar ciri_physint i.region, cluster (ccode)
outreg2 using table20, replace

nbreg hclagOPS2 democracy ciri_orgrights gtd_ngoterror gdppcln pop_ln lnaidpc_adj prio_civwar ciri_physint i.region, cluster (ccode)
outreg2 using table20

nbreg hclagOPS12 democracy ciri_orgrights gtd_ngoterror gdppcln pop_ln lnaidpc_adj prio_civwar ciri_physint i.region, cluster (ccode)
outreg2 using table20


*************************************************
***Appendix A7: Main models w/ year fixed effects
*************************************************

nbreg lagOPS1 democracy ciri_orgrights gtd_ngoterror gdppcln pop_ln lnaidpc_adj prio_civwar ciri_physint i.year, cluster (ccode)
outreg2 using table20, replace

nbreg lagOPS2 democracy ciri_orgrights gtd_ngoterror gdppcln pop_ln lnaidpc_adj prio_civwar ciri_physint i.year, cluster (ccode)
outreg2 using table20

nbreg lagOPS12 democracy ciri_orgrights gtd_ngoterror gdppcln pop_ln lnaidpc_adj prio_civwar ciri_physint i.year, cluster (ccode)
outreg2 using table20


*************************************************
***Appendix A8: Main models w/ disasters declared
*************************************************

nbreg lagOPS1 democracy ciri_orgrights gtd_ngoterror gdppcln pop_ln lnaidpc_adj prio_civwar ciri_physint emdat_appealdisaster3 i.region, cluster (ccode)
outreg2 using table20, replace

nbreg lagOPS2 democracy ciri_orgrights gtd_ngoterror gdppcln pop_ln lnaidpc_adj prio_civwar ciri_physint emdat_appealdisaster3 i.region, cluster (ccode)
outreg2 using table20

nbreg lagOPS12 democracy ciri_orgrights gtd_ngoterror gdppcln pop_ln lnaidpc_adj prio_civwar ciri_physint emdat_appealdisaster3 i.region, cluster (ccode)
outreg2 using table20


**************************************
***Appendix A9: Descriptive statistics
**************************************

sum lagOPS1 lagOPS2 lagOPS12 democracy ciri_orgrights gtd_ngoterror gdppcln pop_ln lnaidpc_adj prio_civwar ciri_physint


********************************************
***Appendix A10: YIO data correlation matrix
********************************************

corr lagOPS1 lagOPS2 lagOPS12 campbell_devingo

